package com.jk.litterapp.domain.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @Project: litter-app
 * @Author: Jack
 * @CreateTime: 2018/1/25 16:33
 * @Describe:
 */
@Entity
@Data
@Table(name="t_book")
@NoArgsConstructor
@AllArgsConstructor
public class Book implements Serializable{

    private static final long serialVersionUID = 1040069681624647511L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "book_name")
    private String bookName;

    @Column(name = "title")
    private String title;

    @Column(name = "author")
    private String author;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
    @CreationTimestamp
    @Column(name = "create_time",nullable = false,updatable = false,columnDefinition = "timestamp default current_timestamp comment '创建时间'")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time",nullable = false,columnDefinition = "timestamp default current_timestamp ON UPDATE CURRENT_TIMESTAMP  comment '修改时间'")
    private Date updateTime;

}
